package drive.RemakeController;

import drive.Model.RoadDisaster;
import drive.RemakeService.ServiceInterface.RoadHazardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/road-hazard")
public class RoadHazardController {

    @Autowired
    private RoadHazardService roadHazardService;

    /**
     * 发布灾害
     * @paramdisasterRequest灾害请求对象
     * @return 操作结果的JSON字符串
     */
    @PostMapping("/publish")
    public String publishDisaster(@RequestBody RoadDisaster roadDisaster) {
        return roadHazardService.publishDisaster(roadDisaster);
    }


    /**
     * 修改灾害状态
     * @paramdisasterUpdateRequest灾害状态更新请求参数
     * @return 操作结果的JSON字符串
     */
    @PutMapping("/update-status")
    public String updateDisasterStatus(@RequestParam int disasterID,String status) {
        return roadHazardService.updateDisasterStatus(disasterID, status);
    }
}